<?php
namespace Home\Controller;
use Think\Controller;
class AddController extends Controller {
	public function uploadImage()
    {
    	// var_dump($_FILES);
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =     './Pic/'; // 设置附件上传根目录
	    $upload->savePath  =     ''; // 设置附件上传（子）目录
	    // 上传文件 
	    $info   =   $upload->upload();
	    $info = current($info);
		$path = '/Pic/'.$info['savepath'].$info['savename'];

	    // var_dump($path);exit();

	    $arr = array(
	    	"code"=> 0,
	    	"msg"=> "成功",
	    	"data"=> array(
	    		"src"=> __ROOT__.$path,
	    		"title"=> $info['savename']
	    		)
			);
	    echo json_encode($arr);
    
    }


}
